<template>
  <el-form :model="localForm" label-width="120px" @input="syncToParent">
    <el-form-item label="SN" prop="sn">
      <el-input v-model="localForm.sn" placeholder="请输入SN" />
    </el-form-item>
    <el-form-item label="系统名称" prop="osName">
      <el-input v-model="localForm.osName" placeholder="请输入系统名称" />
    </el-form-item>
    <el-form-item label="CPU型号" prop="cpuModel">
      <el-input v-model="localForm.cpuModel" placeholder="请输入CPU型号" />
    </el-form-item>
    <el-form-item label="CPU核心数" prop="cpuCore">
      <el-input v-model.number="localForm.cpuCore" placeholder="请输入CPU核心数" type="number" />
    </el-form-item>
    <el-form-item label="CPU速率" prop="cpuFrequency">
      <el-input v-model="localForm.cpuFrequency" placeholder="请输入CPU速率" />
    </el-form-item>
    <el-form-item label="内存" prop="memorySize">
      <el-input v-model="localForm.memorySize" placeholder="请输入内存" />
    </el-form-item>
    <el-form-item label="硬盘" prop="diskSize">
      <el-input v-model="localForm.diskSize" placeholder="请输入硬盘" />
    </el-form-item>
    <el-form-item label="公网地址" prop="publicIp">
      <el-input v-model="localForm.publicIp" placeholder="请输入公网地址" />
    </el-form-item>
    <el-form-item label="私网地址" prop="privateIp">
      <el-input v-model="localForm.privateIp" placeholder="请输入私网地址" />
    </el-form-item>
    <el-form-item label="负责人" prop="createBy">
      <el-input v-model="localForm.createBy" placeholder="请输入负责人" />
    </el-form-item>
    <el-form-item label="创建时间" prop="createTime">
      <el-date-picker v-model="localForm.createTime" type="datetime" placeholder="请选择创建时间"  value-format="YYYY-MM-DD HH:mm:ss"
        format="YYYY-MM-DD HH:mm:ss"   @change="syncToParent"/>
    </el-form-item>
    <el-form-item label="到期时间" prop="exireTime">
      <el-date-picker v-model="localForm.exireTime" type="datetime" placeholder="请选择到期时间" value-format="YYYY-MM-DD HH:mm:ss"
        format="YYYY-MM-DD HH:mm:ss"   @change="syncToParent"/>
    </el-form-item>
  </el-form>
</template>

<script setup>
import { ref, watch } from 'vue';

const props = defineProps({
  modelValue: Object, // 接收弹框的form.specConfig
  isEdit: Boolean,    // 新增/编辑标记
});
const emit = defineEmits(['update:modelValue']);

const localForm = ref({ ...props.modelValue }); // 本地维护表单数据

// 监听props.modelValue变化（如编辑时初始化）
watch(() => props.modelValue, (val) => {
  localForm.value = { ...val };
}, { deep: true });

// 同步本地数据到父组件
const syncToParent = () => {
  emit('update:modelValue', localForm.value);
};
</script>